<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = & get_instance(); 
	$tournament_id = intval($_POST['tournament_id']);
	$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
	$eventCategoryDataArray = $ci->event_category_tournament_entity->getArrayIdAndNameOfEventCategory($tournament_id);	
	$TOURNAMENT = $ci->tournament_entity->init('id',$tournament_id);
?>
<?php if(!$id): ?>
<form action="<?php echo site_url('admin/dataman/tournament_event/event_submit');?>" name="event_submit" id="event_submit" method="post" enctype="multipart/form-data" >
	<input type="hidden" name="tournament_id" id="tournament_id" value="<?php echo $tournament_id;?>" />
	<div class="grid2"><span class="bold">*Event Category:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'event_category_id',
								$options = $eventCategoryDataArray,
								$selected = array(),
								"id='event_category_id'"
							);	?></div>	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Event Name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="name" name="name" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="name_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Odds:</span></div>
	<div class="grid6"><input type="text" maxlength="25" id="odds" name="odds" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="odds_error">Required field.</span></div>
	<div class="clrboth"></div>

	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php else:?>
<form action="<?php echo site_url('admin/dataman/tournament_event/event_submit');?>" name="event_submit" id="event_submit" method="post" enctype="multipart/form-data" >
	<?php 
		$EVENT = $ci->event_tournament_entity->init('id',$id);
	?>
	<input type="hidden" name="id" id="id" value="<?php echo $id;?>" />
	<input type="hidden" name="tournament_id" id="tournament_id" value="<?php echo $tournament_id;?>" />
	
	<div class="grid2"><span class="bold">*Event Category:</span></div>
	<div class="grid6"><?php echo form_dropdown( 'event_category_id',
								$options = $eventCategoryDataArray,
								$selected = array($EVENT->getTournamentEventCategoryId()),
								"id='event_category_id'"
							);	?></div>	
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Event Name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="name" name="name" value="<?php echo $EVENT->getName();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="name_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="grid2"><span class="bold">*Odds:</span></div>
	<div class="grid6"><input type="text" maxlength="25" id="odds" name="odds" value="<?php echo $EVENT->getOdds();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="odds_error">Required field.</span></div>
	<div class="clrboth"></div>

	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php endif;?>